import { Pipe, PipeTransform } from '@angular/core';

@Pipe({
  name: 'jsonFormat'
})
export class JsonFormatPipe implements PipeTransform {
  transform(value: any, indent: number = 2): string {
    try {
      const parsedJson = JSON.parse(value);
      return JSON.stringify(parsedJson, null, indent);
    } catch (error) {
      // 如果解析失败，返回原始值
      return value;
    }
  }
}
